package com.blue.firecat.enums;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.transaction.Transaction;

/**
 * 描述
 * 时间 2017/6/24 14:43
 * 作者 廖林山
 */
public enum ErrorEnum {
    /**
     * 全局错误码
     */
    UNKNOWN(0, "未知"),
    SUCCESS(1,"成功"),
    PARAMETER_CANNOT_NULL(101, "参数不能为空"),
    PARAMETER_INVALID(102, "参数校验失败"),
    CODE_INVALID(103, "验证码错误"),
    SYSTEM_ERROR(999, "系统内部错误"),
    /**
     * 账户类型错误码user
     */

    USER_CODE_ERROR(1001,"验证码错误"),
    USER_PASSWORD_ERROR(1002,"用户不存在或密码错误"),
    USER_CHANGE_PASSWORD_ERROR(1003,"修改密码出错"),
    USER_ALREADY_EXISTS(1004,"账号已存在"),
    USER_DOES_NOT_EXIST(1005,"账号不存在"),
    USER_IS_NOT_ENABLED(1006,"账号未启用"),
    USER_CREATE_ERROR(1007,"创建账号出错"),
    USER_UNABLE_TO_DO(1008,"操作权限不足"),
    USER_MODIFY_ERROR(1009,"修改个人信息出错"),
    USER_MODIFY_SUCCESS(1010,"修改个人信息成功"),
    USER_STATUS_MODIFY_ERROR(1011,"修改用户状态出错"),
    USER_DELETE_ERROR(1012,"删除账号出错"),
    USER_DELETE_ADMIN_ERROR(1013,"不能删除管理员用户"),
    USER_TWO_PASSWORD_ERROR(1014,"两次密码不一致"),
    USER_GOOD(1015,"注册成功,请等待管理员审核"),
    USER_ID_ERROR(1016,"身份证错误,请重新输入"),
    USER_PASSWORD_SEND_EMAIL(1017,"登陆密码已经发送至您的邮箱,请注意查收"),
    USER_NAME_HAS(1018,"登陆名已经注册"),
    USER_ID_CARD_HAS(1019,"身份证已经注册"),
    USER_DOES_NOT_EXIST1(1020,"账号不存在"),
    USER_TYPE_NOT_EXIST(1021,"请选择增加用户的类型"),
    USER_PASSWORD_IS_EMPTY_ERROR(1022,"输入密码为空"),



    /**
     * 游戏类型错误码game
     */
    GAME_ADD_ERROR(2000,"游戏添加出错"),
    GAME_DELETE_ERROR(2001,"游戏删除失败"),
    GAME_IS_EMPTY(2002,"游戏不存在"),
    GAME_ADD_SUCCESS(2003,"游戏增加成功~"),
    GAME_NAME_NOT_EMPTY(2004,"游戏名不能为空~"),

    /**
     * 订单类型错误码order
     */
    ORDER_CREATE_ERROR(3001,"创建订单出错"),
    ORDER_DOES_NOT_EXIST(3003,"订单不存在"),
    ORDER_HAS_EXPIRED(3004,"订单已过期"),
    ORDER_IS_IN_THE_LOTTERY(3005,"订单正在代练中"),
    ORDER_MODIFICATION_STATUS_ERROR(3006,"订单修改状态出错"),
    ORDER_REVIEW_DOES_NOT_PASS(3007,"订单审核不通过"),
    ORDER_SETTLEMENT_IS_ABNORMAL(3008,"订单结算出现异常"),
    ORDER_DELETE_ERROR(3009,"订单删除失败"),
    ORDER_HAS_BEEN_LOCKED(3010,"订单已被锁定"),
    ORDER_IS_NOT_WAITING(3011,"订单不是待接手状态"),
    ORDER_HAVEING_APPLIED(3012,"订单正在审核中"),
    ORDER_NO_DELETE(3013,"订单不是有效的删除状态,必须是过期,未接手或者异常单"),
    ORDER_UPDATE_ERROR(3014,"订单更新失败"),
    ORDER_DATA_ERROR(3015,"订单编号不能为空"),
    ORDER_EXITS(3016,"订单号已存在"),
    /**
     * 交易类型错误码trade
     */
    TRADE_IMAGE_UPLOAD_ERROR(4001,"图片上传出错"),
    TRADE_CREATE_FAIL(4007,"创建失败"),
    TRADE_NOT_FOUND(4008,"交易不存在"),
    TRADE_STATUS_ERROR(4009,"交易状态错误"),
    TRADE_DELETE_ERROR(4010,"交易撤销失败"),
    TRADE_AUDIT_ERROE(4011,"审核失败"),
    TRADE_REMARK_NOT_PASS(4012,"交易审核不通过"),
    TRADE_REMARK_CHECK_NOT_PASS(4013,"交易验证不通过"),
    TRADE_MODIFIED_STATUS_ERROR(4017,"交易状态修改出错"),

    /**
     * 图片上传
     */
    PIC_NUM_MUCH(5000,"图片上传成功");


    private int code;
    private String value;

    ErrorEnum(int code, String value) {
        this.code = code;
        this.value = value;
    }

    public static String getValueByCode(int code) {
        for (ErrorEnum type : ErrorEnum.values()) {
            if (code == type.getCode()) {
                return type.getValue();
            }
        }
        return UNKNOWN.value;
    }


    public int getCode() {
        return code;
    }

    public String getValue() {
        return value;
    }


    }
